/*
wellbye：这个文件是自动生成的，不要手工修改！ 
*/
using System;
using ILRuntime.CLR.Method;
using ILRuntime.Other;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;

[ILRAdaptor]
public class ILRAdaptor_EventArgs : CrossBindingAdaptor
{
    public override Type BaseCLRType { get { return typeof(System.EventArgs); } }
    public override Type AdaptorType { get { return typeof(Adaptor); } }

    public override object CreateCLRInstance(ILRuntime.Runtime.Enviorment.AppDomain appDomain, ILTypeInstance instance)
    {
        return new Adaptor(appDomain, instance); //创建一个新的实例
    }

    //实际的适配器类需要继承你想继承的那个类，并且实现CrossBindingAdaptorType接口
    public class Adaptor : System.EventArgs, CrossBindingAdaptorType
    {
        ILTypeInstance instance;
        ILRuntime.Runtime.Enviorment.AppDomain appDomain;

        public Adaptor() { }

        public Adaptor(ILRuntime.Runtime.Enviorment.AppDomain appDomain, ILTypeInstance instance)
        {
            this.appDomain = appDomain;
            this.instance = instance;
        }

        public ILTypeInstance ILInstance { get { return instance; } }

        
        
        IMethod methodEquals0;
        bool isCallingEquals0= false;
        
            public override System.Boolean Equals(System.Object p0) 
            { 
                if (methodEquals0 == null && instance!=null )
                {
                    methodEquals0 = instance.Type.GetMethod("Equals", 1);
                }
                if (methodEquals0 != null && !isCallingEquals0)
                {
                    isCallingEquals0 = true;

                    try{
                        
                        //有参数，打包成数组
                        object[] param=new object[]{
                                p0,
                        };
                        object ret = appDomain.Invoke(methodEquals0, instance, param );
                        
                        
                        isCallingEquals0 = false;

                        
                        return (System.Boolean)ret;
                        
                    }
                    catch(Exception e){
                        mb.App.logger.Log("**** Catch Exception In Equals *****");
                        mb.App.logger.Log(e.ToString());
                        mb.App.logger.Log("**********************");
                        throw e;
                    }
                }
                else
                {
                    
                    
                        
                            return base.Equals(p0);
                        
                    

                }
            }
        
        
        
        IMethod methodGetHashCode1;
        bool isCallingGetHashCode1= false;
        
            public override System.Int32 GetHashCode() 
            { 
                if (methodGetHashCode1 == null && instance!=null )
                {
                    methodGetHashCode1 = instance.Type.GetMethod("GetHashCode", 0);
                }
                if (methodGetHashCode1 != null && !isCallingGetHashCode1)
                {
                    isCallingGetHashCode1 = true;

                    try{
                        
                        //无参数调用
                        object ret = appDomain.Invoke(methodGetHashCode1, instance, null );
                        
                        
                        
                        isCallingGetHashCode1 = false;

                        
                        return (System.Int32)ret;
                        
                    }
                    catch(Exception e){
                        mb.App.logger.Log("**** Catch Exception In GetHashCode *****");
                        mb.App.logger.Log(e.ToString());
                        mb.App.logger.Log("**********************");
                        throw e;
                    }
                }
                else
                {
                    
                    
                        
                            return base.GetHashCode();
                        
                    

                }
            }
        
        
        
        IMethod methodGetType2;
        bool isCallingGetType2= false;
        
            public  System.Type GetType() 
            { 
                if (methodGetType2 == null && instance!=null )
                {
                    methodGetType2 = instance.Type.GetMethod("GetType", 0);
                }
                if (methodGetType2 != null && !isCallingGetType2)
                {
                    isCallingGetType2 = true;

                    try{
                        
                        //无参数调用
                        object ret = appDomain.Invoke(methodGetType2, instance, null );
                        
                        
                        
                        isCallingGetType2 = false;

                        
                        return (System.Type)ret;
                        
                    }
                    catch(Exception e){
                        mb.App.logger.Log("**** Catch Exception In GetType *****");
                        mb.App.logger.Log(e.ToString());
                        mb.App.logger.Log("**********************");
                        throw e;
                    }
                }
                else
                {
                    
                    
                        
                            return base.GetType();
                        
                    

                }
            }
        
        
        
        IMethod methodToString3;
        bool isCallingToString3= false;
        
            public override System.String ToString() 
            { 
                if (methodToString3 == null && instance!=null )
                {
                    methodToString3 = instance.Type.GetMethod("ToString", 0);
                }
                if (methodToString3 != null && !isCallingToString3)
                {
                    isCallingToString3 = true;

                    try{
                        
                        //无参数调用
                        object ret = appDomain.Invoke(methodToString3, instance, null );
                        
                        
                        
                        isCallingToString3 = false;

                        
                        return (System.String)ret;
                        
                    }
                    catch(Exception e){
                        mb.App.logger.Log("**** Catch Exception In ToString *****");
                        mb.App.logger.Log(e.ToString());
                        mb.App.logger.Log("**********************");
                        throw e;
                    }
                }
                else
                {
                    
                    
                        
                            return base.ToString();
                        
                    

                }
            }
        
        
    }
}